/*
 * @Author: Ryan Huang
 * @Description:
 * @Date: 2019-04-27 23:09:09
 */
package main

import "fmt"

var in chan int
var out chan int

func run() {
	for {
		select {
		case i := <-in:
			fmt.Println(i, "in")
			if i > 5 {
				out <- i - 5
			}
		case i := <-out:
			fmt.Println(i, "out")
		}
	}
}
func main() {
	in = make(chan int)
	out = make(chan int)
	go run()
	for i := 0; i < 10; i++ {
		go func() {
			in <- i
		}()
	}
	for {

	}
	return
}
